/*
* 引入vue和路由
* */

import Vue from 'vue'
import Router from 'vue-router'
/* Layout */

const login = () => import("../views/login")
const view404 = import('@/views/404')
const index = () => import("../views/index")
const welcome = () => import("../views/welcome")
const course = () => import("../views/xkxt/course")
const student = () => import("../views/xkxt/student")
const teacher = () => import("../views/xkxt/teacher")
const schedule = () => import("../views/xkxt/schedule")
const selectCourse = () => import("../views/xkxt/selectCourse")
const selection = () => import("../views/xkxt/selection")
const mySelection = () => import("../views/xkxt/mySelection")
const studentStatistic = () => import("../views/statistic/studentStatistic")
const teacherStatistic = () => import("../views/statistic/teacherStatistic")
const courseStatistic = () => import("../views/statistic/courseStatistic")
const help = () => import("../views/help/help")

Vue.use(Router)     //安装路由插件

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
export default new Router({
    mode: 'history',
    routes: [
        {path: '/login', component: login, hidden: true},
        {path: '/404', component: view404, hidden: true},
        {path: '/', redirect: '/index',},
        {
            path: '/index',
            component: index,
            redirect: '/welcome',
            children: [
                {
                    path: '/welcome',
                    component: welcome,
                    name: 'welcome',
                },
                {
                    path: '/student',
                    component: student,
                },
                {
                    path: '/teacher',
                    component: teacher,
                },
                {
                    path: '/course',
                    component: course,
                },
                {
                    path: '/schedule',
                    component: schedule,
                },
                {
                    path: '/selectCourse',
                    component: selectCourse,
                },
                {
                    path: '/selection',
                    component: selection,
                },
                {
                    path: '/mySelection',
                    component: mySelection,
                },
                {
                    path: '/studentStatistic',
                    component: studentStatistic,
                    name: 'studentStatistic'
                },
                {
                    path: '/teacherStatistic',
                    component: teacherStatistic,
                    name: 'teacherStatistic'
                },
                {
                    path: '/courseStatistic',
                    component: courseStatistic,
                    name: 'courseStatistic'
                },
                {
                    path: '/help',
                    component: help,
                    name: 'help'
                }
            ]
        },

    ]
})
